package com.ruoyi.common.enums;

import java.util.NoSuchElementException;

/**
 * @author zcy
 * @description 工单类型枚举
 * @date 2021/1/24
 **/
public enum OrderType {
    /**
     * 巡检工单：1
     */
    INSPECT_ORDER(Integer.valueOf("1")) {
        public String getOrderType() {
            return "巡检工单";
        }
    },
    /**
     * 保养工单：2
     */
    MAINTAIN_ORDER(Integer.valueOf("2")) {
        public String getOrderType() {
            return "保养工单";
        }
    },
    /**
     * 维护工单：3
     */
    UPHOLD_ORDER(Integer.valueOf("3")) {
        public String getOrderType() {
            return "维护工单";
        }
    },
    /**
     * 维修工单：4
     */
    REPAIR_ORDER(Integer.valueOf("4")) {
        public String getOrderType() {
            return "维修工单";
        }
    };


    private OrderType(Integer key) {
        this.key = key;
    }

    private Integer key;

    public Integer getKey() {
        return this.key;
    }

    public abstract String getOrderType();

    public static OrderType getOrderType(Integer code) {
        for (OrderType orderType : OrderType.values()) {
            if (code.equals((orderType.getKey())))
                return orderType;
        }
        throw new NoSuchElementException(code.toString());
    }
}
